package Test;

public class 快速排序 {
    void quick(int[] arr,int left,int right){
        if(left<right){
            int index=getindex(arr,left,right);
            quick(arr,left,index-1);
            quick(arr,index+1,right);
        }
    }

    int getindex(int[] arr,int left,int right){
        int temp=arr[left];
        while (left<right){
            while (arr[right]>=temp&&left<right){
                right--;
            }
            arr[left]=arr[right];
            while (arr[left]<=temp&&right>left){
                left++;
            }
            arr[right]=arr[left];


        }
        arr[left]=temp;
        return left;
    }
}
